package com.usian.controller;

import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.usian.pojo.User;
import com.usian.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
public class UserController {

    @Autowired
    private UserService userService;

    /**
     * 结合sentinel 限流后返回托底数据
     * @param id
     * @return
     */

    @RequestMapping("/findById/{id}")
    public User findById(@PathVariable Integer id){
        return userService.findById(id);
    }


    @GetMapping("/findByName")
    public User findByName(@RequestParam Integer id,@RequestParam String name){
        System.out.println("===="+name);
        return userService.findById(id);
    }

    @PostMapping("/findByUser")
    public User findByUser(@RequestBody User user){
        return userService.findById(user.getId());
    }
}
